package cn.stylefeng.guns.modular.hxl.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.core.util.DateUtil;
import cn.stylefeng.guns.modular.hxl.entity.HxlArea;
import cn.stylefeng.guns.modular.hxl.model.params.HxlAreaParam;
import cn.stylefeng.guns.modular.hxl.service.HxlAreaService;
import cn.stylefeng.guns.sys.modular.system.entity.User;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.guns.sys.modular.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;


/**
 * 好想来-仓库信息控制器
 *
 * @author 
 * @Date 2025-06-30 09:18:16
 */
@Controller
@RequestMapping("/hxlArea")
public class HxlAreaController extends BaseController {

    private String PREFIX = "/hxl/hxlArea";

    @Autowired
    private HxlAreaService hxlAreaService;

    @Autowired
    private UserService userService;

    /**
     * 跳转到主页面
     *
     * @author 
     * @Date 2025-06-30
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/hxlArea.html";
    }

    /**
     * 新增页面
     *
     * @author 
     * @Date 2025-06-30
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/hxlArea_add.html";
    }

    /**
     * 编辑页面
     *
     * @author 
     * @Date 2025-06-30
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/hxlArea_edit.html";
    }

    /**
     * 新增接口
     *
     * @author 
     * @Date 2025-06-30
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(HxlAreaParam hxlAreaParam) {
        User user = userService.getcurrentUser();
        hxlAreaParam.setCreateUser(user.getUserId());
        hxlAreaParam.setCreateTime(new Date());
        this.hxlAreaService.add(hxlAreaParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author 
     * @Date 2025-06-30
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(HxlAreaParam hxlAreaParam) {
        User user = userService.getcurrentUser();
        hxlAreaParam.setUpdateUser(user.getUserId());
        hxlAreaParam.setUpdateTime(new Date());
        this.hxlAreaService.update(hxlAreaParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author 
     * @Date 2025-06-30
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(HxlAreaParam hxlAreaParam) {
        this.hxlAreaService.delete(hxlAreaParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author 
     * @Date 2025-06-30
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(HxlAreaParam hxlAreaParam) {
        HxlArea detail = this.hxlAreaService.getById(hxlAreaParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author 
     * @Date 2025-06-30
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(HxlAreaParam hxlAreaParam,String condition ) {
        return this.hxlAreaService.findPageBySpec(hxlAreaParam,condition);
    }

}


